<template>
  <div class="shareCenter">
    <ContentBox title="分享中心" @left="back" :fixed="true" :ostyle="style" titlecolor="block">
      <template slot="oleft"><van-icon color="#000" name="arrow-left"/></template>
    </ContentBox>
    <notice :top="$remToPx('0.88')"></notice>
    <div class="wrap" :style="{backgroundImage:`url(${$img('promotionBg.png')})`}">
      <div class="name acea-row row-center-wrapper">
        <div>当前佣金</div>
        <router-link class="record" :to="'/user/cashrecord'">
          提现记录<span :style="{backgroundImage:`url(${$img('right.png')})`}"></span>
        </router-link>
      </div>
      <div class="num">{{mData.commissionCount}}</div>
      <div class="profit">
        <div class="item">
          <div>昨日收益</div>
          <div class="money">{{mData.lastDayCount}}</div>
        </div>
        <div class="item">
          <div>累积已提</div>
          <div class="money">{{mData.extractCount}}</div>
        </div>
      </div>
    </div>
    <div @click="toCash" class="bnt bg-color-red">立即提现</div>
    <div class="list clear">
      <router-link
        class="item fl"
        to="/user/poster"
      >
        <div class="bg" :style="{backgroundImage:`url(${$img('roced.png')})`}"></div>
        <div>推广名片</div>
      </router-link>
      <router-link
        class="item fr"
        to="/user/promoter_list"
      >
        <div class="bg" :style="{backgroundImage:`url(${$img('stat.png')})`}"></div>
        <div>推广人统计</div>
      </router-link>
      <router-link
        class="item fl"
        to="/user/commission"
      >
        <div class="bg" :style="{backgroundImage:`url(${$img('money_bag.png')})`}"></div>
        <div>佣金明细</div>
      </router-link>
      <router-link
        class="item fr"
        to="/user/promoter_order"
      >
        <div class="bg" :style="{backgroundImage:`url(${$img('select.png')})`}"></div>
        <div>推广人订单</div>
      </router-link>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      style: {
        backgroundColor: '#f6f6f6'
      },
      mData: ''
    }
  },
  methods: {
    back () {
      if (this.$store.state.pl === 'H5') {
        this.$router.go(-1)
      } else if (this.$store.state.pl === 'ANDROID') {
        AndroidJsBridge.finish()
      } else if (this.$store.state.pl === 'IOS') {
        window.iosCallHandler('popVC')
      }
    },
    toCash () {
      this.$router.push({
        name: 'user_cash'
      })
    },
    getData () {
      this.$axios.get('/api/commission').then(res => {
        if (res.status === 200) {
          this.mData = res.data
        }
      })
    }
  },
  created () {
    this.getData()
  }
}
</script>

<style lang="scss" scoped>
@import './style.scss';
</style>
